package com.huifaapp.mall.activity;

import android.net.http.SslError;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.webkit.SslErrorHandler;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

import com.huifaapp.mall.R;

/**
 * Created by Administrator on 2018/1/4.
 */

public class RankingRanNo1HtmlActivity extends AppCompatActivity{

    private WebView ll_web_container;
    private String url;
    private ImageView iv_html_back;
    private TextView tv_html_tilte;
    private String title;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jd_html);
        Log.v("shiran","-------------WEBACTIVITY-----------------");

        ll_web_container = (WebView) findViewById(R.id.ll_container);
        iv_html_back= (ImageView) findViewById(R.id.iv_html_back);
        iv_html_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        tv_html_tilte= (TextView) findViewById(R.id.tv_html_tilte);
        url = getIntent().getStringExtra("url");
        title = getIntent().getStringExtra("title");
        tv_html_tilte.setText(title +"");
        Log.e("TAF", url +"-----------------------------");
        ll_web_container.loadUrl(url);
        ll_web_container.getSettings().setJavaScriptEnabled(true);
        WebviewSettingsinit();
    }

    private void WebviewSettingsinit() {
        ll_web_container.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                return super.shouldOverrideUrlLoading(view, url);

            }
        });
        ll_web_container.setWebViewClient(new WebViewClient() {

            @Override
            public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
                handler.proceed();
            }
        });

    }
}
